<include file="Public/head"/>

<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>
            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="cf">
                            <form class="form-inline" action="" method="get">
                                <a class="btn btn-info" href="{:U('add')}" value="">新增</a>
                                <label class="inline">平台分类</label>
                                <select name="cid" class="form-control">
                                    <option value="">--全部--</option>
                                    <volist name="category" id="vo">
                                    <option value="{$vo['id']}" <if condition="$cid eq $vo['id']">selected</if>>--{$vo.title}--</option>
                                    </volist>
                                </select>
                                <label class="inline">会员等级</label>
                                <select name="user_level" class="form-control">
                                    <option value="">--全部--</option>
                                    <volist name="user_level_list" id="vo">
                                    <option value="{$vo['id']}" <if condition="$level_id eq $vo['id']">selected</if>>--{$vo.title}--</option>
                                    </volist>
                                </select>
                                <label class="inline">任务状态</label>
                                <select name="status" class="form-control">
                                    <option value="">--全部--</option>
                                    <option value="1" <if condition="$status eq 1">selected</if>>--进行中--</option>
                                    <option value="2" <if condition="$status eq 2">selected</if>>--已完成--</option>
                                    <option value="3" <if condition="$status eq 3">selected</if>>--已过期--</option>
                                </select>
                                <label class="inline">支付状态</label>
                                <select name="pay_status" class="form-control">
                                    <option value="">--全部--</option>
                                    <option value="-1" <if condition="$pay_status eq -1">selected</if>>--待支付--</option>
                                    <option value="1" <if condition="$pay_status eq 1">selected</if>>--已支付--</option>
                                    <option value="2" <if condition="$pay_status eq 2">selected</if>>--已提交--</option>
                                </select>
                                <label class="inline">关键字</label>
                                <input type="text" name="title" value="{:I('title')}" style="width:220px;" placeholder="输入任务标题、发布人、任务单号" class="form-control">
                                <button type="submit" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    搜索
                                </button>
                            </form>
                        </div>
                        <div class="space-4"></div>
                        <form id="form" method="post" action="{:U('delete')}">
                        	<input name="p" type="hidden" value="{$p}"/>
                            <table class="table table-striped table-bordered">
                                <thead>
                                <tr>
                                    <th class="center"><input class="check-all" type="checkbox" value=""></th>
                                    <th>任务单号</th>
                                    <th>所属分类</th>
                                    <th>任务标题</th>
                                    <th>任务单价</th>
                                    <th>任务数量</th>
                                    <th>已完成数</th>
                                    <th>服务费</th>
                                    <th>总价</th>
                                    <th>接单会员等级</th>
                                    <th>任务要求</th>
                                    <th>发布人</th>
                                    <th class="<if condition="$field eq 't'">sorting_{$sort}<else/>sorting</if> sort_tag" field="t">发布时间</th>
                                    <th class="<if condition="$field eq 'end_t'">sorting_{$sort}<else/>sorting</if> sort_tag" field="end_t">截止日期</th>
                                    <th>任务状态</th>
                                    <th>支付状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <empty name="list">
                                	<tr>
                                		<td colspan="17" style="text-align:center;">暂时没有数据</td>
                                	</tr>
                                <else/>
                                	<volist name="list" id="val">
                                    <tr>
                                        <td class="center"><input class="ids" type="checkbox" name="ids[]"
                                                                  value="{$val['id']}"></td>
                                        <td>{$val['task_no']}</td>                          
                                        <td>{$val['category_title']}</td>
                                        <td>{$val['title']}</td>
                                        <td>{$val['price']}</td>
                                        <td>{$val['num']}</td>
                                        <td>{$val['hasdid_num']}</td>
                                        <td>{$val['service_price']}</td>
                                        <td>{$val['amount_price']}</td>
                                        <td>{$val['level_info']}</td>
                                        <td>{$val['money_info']}</td>
                                        <td>{$val['author']}</td>
                                        <td>{$val['t']|date="Y-m-d H:i:s",###}</td>
                                        <td>{$val['end_t']}</td>
                                        <td>
                                        	<if condition="$val['status'] eq 1">进行中</if>
                                        	<if condition="$val['status'] eq 2">已完成</if>
                                        	<if condition="$val['status'] eq 3">已过期</if>
                                        </td>
                                        <td>
                                        	<if condition="$val['pay_status'] eq 1">已支付</if>
                                        	<if condition="$val['pay_status'] eq 0">待支付</if>
                                        	<if condition="$val['pay_status'] eq 2">已提交</if>
                                        </td>
                                        <td>
                                        	<if condition="$val['on_top'] eq 1">
                                        	<a href="{:U('ontop',array('id'=>$val['id'],'p'=>$p,'ontop'=>99,'cid'=>$cid,'user_level'=>$level_id,'status'=>$status,'pay_status'=>$pay_status))}" title="" style="color:blue">置顶</a>&nbsp;&nbsp;
                                        	<else/>
                                        	<a href="{:U('ontop',array('id'=>$val['id'],'p'=>$p,'ontop'=>1,'cid'=>$cid,'user_level'=>$level_id,'status'=>$status,'pay_status'=>$pay_status))}" title="" style="color:red">取消置顶</a>&nbsp;&nbsp;
                                        	</if>
                                        	<a href="{:U('update',array('id'=>$val['id'],'p'=>$p))}">修改</a>&nbsp;&nbsp;
                                         	<a href="javascript:;" val="{:U('delete',array('ids'=>$val['id'],'p'=>$p))}" class="del">删除</a>
                                        </td>
                                    </tr>
                                	</volist>
                                </empty>
                                </tbody>
                            </table>
                        </form>
                        <div class="cf">
                            <input id="submit" class="btn btn-info" type="button" value="删除">
                        </div>
                        {$page}
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $(".check-all").click(function () {
            $(".ids").prop("checked", this.checked);
        });
        $(".ids").click(function () {
            var option = $(".ids");
            option.each(function (i) {
                if (!this.checked) {
                    $(".check-all").prop("checked", false);
                    return false;
                } else {
                    $(".check-all").prop("checked", true);
                }
            });
        });
        $("#submit").click(function () {
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除所选文章？",
                callback: function (result) {
                    if (result) {
                        $("#form").submit();
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
        $(".del").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "是否要该文章？",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
    })
    
    $(function(){
        //table排序
		$(".sort_tag").each(function(){
			var th = $(this),thIndex = th.index(),inverse = true;
			th.click(function(){
				var tag = $(this).attr("class");
				tag = tag.substring(0,tag.indexOf(" "));
				if(tag=='sorting_asc'){
					sortTable($(this).attr("field"),"desc");
				}else if(tag=='sorting_desc'){
					sortTable($(this).attr("field"),"asc");
				}else if(tag=='sorting'){
					sortTable($(this).attr("field"),"asc");
				}
				
			});
		});

	});
    
    function sortTable(field,sort){
		var cid = "{$cid}";
		var user_level = "{$level_id}";
		var status = "{$status}";
		var pay_status = "{$pay_status}";
		var title = "{:I('title')}";
		location.href = "{:U('index')}?field="+field+"&sort="+sort+"&cid="+cid+"&user_level="+user_level+"&status="+status+"&pay_status="+pay_status+"&title="+title;
	}
</script>
</body>
</html>
